package com.chis.childcheck;

import com.alibaba.fastjson.JSON;
import com.chis.jm.bean.ChildSynInfoBean;

import java.io.BufferedReader;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;

/**
 * 
 * @Description 
 * @Company zwx
 * @author wlj
 * @version 2019年08月14日
 */
public class ChildCode {
    public static void main(String[] args) {
        String files = args[0];
        String scom = args[1];
        File file1 = new File(files);
//        File file2 = new File("C:\\work2019\\JmDev\\Jm_Test_Prj\\JmCoolTest\\target\\2.log");
        FileReader m = null;
//        FileWriter fileWriter = null;
        try {
            m = new FileReader(file1);
//            fileWriter = new FileWriter(file2);
        } catch (Exception e) {
            e.printStackTrace();
        }
        BufferedReader reader = new BufferedReader(m);
        List<String> list = new ArrayList<>();
        while (true) {
            String nextline = null;
            try {
                nextline = reader.readLine();
                if (nextline != null && nextline.length() > 8) {
//                    System.out.println(nextline);

                    if(nextline.startsWith("{")){
                        List<String> list1 = getchilcode(nextline);
                        for(String s : list1){
                            if(!list.contains(s) && (scom.equals("") || !scom.contains(s))){
                                list.add(s);
                            }
                        }

                    }


                }
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (nextline == null) break;
        }
        for(String sd : list ){
            System.out.println(sd);
        }

    }

    public static List<String> getchilcode(String s){
        List<String> list = new ArrayList<>();
        String[] strings = s.split(",");
        for(String s1 : strings){
            if(s1.contains("chilCode")){
                list.add(s1.substring(s1.indexOf("chilCode")+10));
            }
            if(s1.contains("inocChilId")){
                list.add(s1.substring(s1.indexOf("inocChilId")+12));
            }


        }
        return list;
    }
}
